package reduce.fz.com.reduce.fragment;


import android.app.Service;
import android.os.Bundle;
import android.app.Fragment;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.alibaba.fastjson.TypeReference;

import reduce.fz.com.reduce.R;
import reduce.fz.com.reduce.abstracts.AbResponseListener;
import reduce.fz.com.reduce.bean.Team;
import reduce.fz.com.reduce.bean.result.Result;
import reduce.fz.com.reduce.custom.delegate.RecyclerViewDelegate;
import reduce.fz.com.reduce.fragment.base.BaseFragment;
import reduce.fz.com.reduce.service.TeamService;
import reduce.fz.com.reduce.util.ServiceBuilder;

/**
 * team详情动态页签
 */
public class TeamDynamicFragment extends BaseViewPagerFragment implements View.OnClickListener {
    private Team team;
    private Long teamid;
    private TeamDynamicListFragment dynamicListFragment;
    private RecyclerViewDelegate mRecyclerViewDelegate = new RecyclerViewDelegate();

    private TextView mTeamDynamicTitle;
    private FrameLayout dynamicListContainer;
    private TeamService teamService = ServiceBuilder.builderTeamService(null);


    public static TeamDynamicFragment create(Team team, int position) {
        TeamDynamicFragment fragment = new TeamDynamicFragment();
        Bundle bundle = new Bundle();
        bundle.putSerializable("team", team);
        bundle.putInt(BUNDLE_FRAGMENT_INDEX, position);
        fragment.setArguments(bundle);
        return fragment;

    }


    public TeamDynamicFragment() {
    }

    public void attachDynamicListFragment() {

        dynamicListFragment = TeamDynamicListFragment.create(team.teamid);
        getChildFragmentManager().beginTransaction().replace(R.id.team_dynamic_list_container, dynamicListFragment).commit();
    }


    public void initWidget(View view) {
        mTeamDynamicTitle = (TextView) view.findViewById(R.id.team_dynamic_title);
        dynamicListContainer = (FrameLayout) view.findViewById(R.id.team_dynamic_list_container);

    }


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        team = (Team) getArguments().getSerializable("team");
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_team_dynamic, container, false);
        initWidget(view);
        attachDynamicListFragment();
        return view;
    }


    @Override
    public void onClick(View view) {
        switch (view.getId()) {
        }
    }


    @Override
    public boolean isViewBeingDragged(MotionEvent event) {
        Boolean temp = dynamicListFragment.isViewBeingDragged(event);
        return temp;
    }
}
